<?php require_once('../Connections/cnn.php');

 
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "Admin,User";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_usuarios = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_usuarios = $_SESSION['MM_Username'];
}
mysql_select_db($database_cnn, $cnn);
$query_usuarios = sprintf("SELECT * FROM usuario WHERE Email = %s", GetSQLValueString($colname_usuarios, "text"));
$usuarios = mysql_query($query_usuarios, $cnn) or die(mysql_error());
$row_usuarios = mysql_fetch_assoc($usuarios);
$totalRows_usuarios = mysql_num_rows($usuarios);
?>

<!doctype html>
<html>
<!-- InstnceBegin template="/Templates/plantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Ventas</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstnceEndEditable -->
<link href="../css/estilo.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../css/demo.css" />
<link rel="stylesheet" type="text/css" href="../css/style3.css" />
<link href="../css/menu3.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- InstanceBeginEditable name="1" -->
<!-- Skitter JS -->
<![endif]-->
<!-- InstanceEndEditable -->
</head>
<body>
<div class="container">
  <header> <img src="../images/banner.png" width="960" height="194" />
    <ul class="menu3">
      <li> <a href="#">Bienvenido/@: <?php echo $row_usuarios['Usuario']; ?></a>
        <ul>
          <li><a href="<?php echo $logoutAction ?>" class="auvi">Cerrar Sesion</a></li>
        </ul>
      </li>
    </ul>
  </header>
  <br>
  <br>
  <br>

  <!-- InstanceBeginEditable name="2" -->
  <ul class="ca-menu">
    <li> <a href="lista_prod.php"> <span class="ca-icon">S</span>
      <div class="ca-content">
        <h2 class="ca-main">Administración General</h2>
        <h3 class="ca-sub">Productos, Categorias y Sucursales</h3>
      </div>
    </a> </li>
    <li> <a href="lista_user.php"> <span class="ca-icon">U</span>
      <div class="ca-content">
        <h2 class="ca-main">Administración de Usuarios</h2>
        <h3 class="ca-sub">Lista de Usuarios y Privilegios</h3>
      </div>
    </a> </li>
    <li> <a href="lista_slider.php"> <span class="ca-icon">I</span>
      <div class="ca-content">
        <h2 class="ca-main">Administración de Slider</h2>
        <h3 class="ca-sub">Agrega o Elimina Imagenes</h3>
      </div>
    </a> </li>        <script> 
function abrir(url) { 
open(url,'','top=75,left=150,width=900,height=500') ; 
} 
</script> 
    <li> <a href="javascript:abrir('chat/operator/login.php')"> <span class="ca-icon">d</span>
      <div class="ca-content">
        <h2 class="ca-main">Administración del Chat</h2>
        <h3 class="ca-sub">Consultas de los Clientes</h3>
      </div>
    </a> </li>
  </ul>
  <div id="numeros6">
    <h3>Bienvenido/@: <?php echo $row_usuarios['Nombre']; ?> <?php echo $row_usuarios['Apellido']; ?></h3>
    <br>
    <p> Bienvenido a la administración de su sitio web. En esta área usted puede realizar el mantenimiento del sitio y de la información     que en el se encuentra. <br>
      Para cada una de las opciones del lado izquierdo se realizan varias operaciones para poder Agregar, Modificar y Eliminar ya sea
      productos, usarios e incluso los comentarios con los que se comunican con el cliente. </p>
  </div>
  <!-- InstanceEndEditable -->
  <!-- script del menu -->
  <script type="text/javascript" language="javascript" src="../js/jquery.min.js"></script>
  <footer>
    <h3>Super Gangas</h3>
  </footer>
  <!-- end .container -->
</div>
</body>
<!-- InstanceEnd -->
</html>
<?php
mysql_free_result($usuarios);
?>
